<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<script src="js/mui.min.js"></script>
		<script src="js/libs/zepto.js"></script>
		<script src="js/libs/vue.js"></script>
		<script src="js/common.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			mui.plusReady(function() {
				common.ajax('/index/getImgs', {}, function(data) {
					if(data.code == 1) {
						if(!data.data.imgs || data.data.imgs.length<=0){
							versions()
							return
						}
						var wp = plus.webview.create('html/mask/advertisement.html', 'html/mask/advertisement.html', {}, {
							preate: data.data
						})
						wp.show('fade-in');
					}else{
						versions()
					}
				}, true, 'get')

				if(!plus.webview.getWebviewById('ylindex.html')) {
					var styles = {}
					if(plus.device.model == 'iPhoneX') {
						styles = {
							top: '0',
							bottom: '34px',
							background: '#fff'
						}
					}

					plus.webview.open('html/home/ylindex.html', 'ylindex.html', styles, 'fade-in')
				}






			  function versions(){
			  	var versions = mui.os.ios ? 2 : 1
				common.ajax('/p/userhome/getVersion', {
					platform: versions
				}, function(data) {
					if(data.code == 1) {
						localStorage.removeItem('toupdate')
						plus.runtime.getProperty(plus.runtime.appid, function(inf) {
							var wgtVer = inf.version;
							if(data.data.newVer > wgtVer) {
								var wp = plus.webview.create('html/mask/toupdate.html', 'html/mask/toupdate.html', {
									scrollIndicator: 'none',
									scalable: false,
									popGesture: 'none',
									background: 'transparent'
								}, {
									preate: data.data
								})
								wp.show('fade-in');
							}
						});
					} else {
						localStorage.setItem('toupdate', true)
					}
				}, true, 'get')
			  }






//				if(!plus.webview.getWebviewById('loading.html')) {
//					plus.webview.create("html/mask/loading.html", "loading.html", {
//						background: 'transparent',
//						zindex: 1000,
//						top: '0',
//						bottom: '0',
//					});
//				}

				if(common.data && common.data.token) {
					var auth = {
						auth: "YL " + common.data.token
					}
				}
				//请求后台tokan过期问题
				mui.ajax(common.urls + '/p/userhome', {
					data: {},
					dataType: 'json', //服务器返回json格式数据
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					headers: auth,
					success: function(data) {
						if(data.code == '-10') {
							localStorage.removeItem('userData')
						}
					}
				});
			})
		</script>
	</body>

</html>